package com.iqiyi.pps.epg.core.dao.basement;

import com.iqiyi.pps.epg.core.dao.base.HibernateDao;
import com.iqiyi.pps.epg.core.dao.base.Page;
import com.iqiyi.pps.epg.core.dao.base.PropertyFilter;
import com.iqiyi.pps.epg.core.model.basement.ConstantsMap;
import org.hibernate.criterion.Criterion;
import org.hibernate.criterion.Restrictions;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * Created by IntelliJ IDEA.
 * User: QIYI
 * Date: 12-8-27
 * Time: 下午5:02
 * To change this template use File | Settings | File Templates.
 */
@Component
public class ConstantsMapDao extends HibernateDao<ConstantsMap, Long> {

    /**
     * 分页获取数据
     *
     * @param page
     * @param filters
     * @return Page<UseType>
     */
    public Page<ConstantsMap> getConstantsMapList(final Page<ConstantsMap> page, final List<PropertyFilter> filters) {
        return findPage(page, filters);
    }

    /**
     * @param type
     * @param code
     * @return
     */
    public ConstantsMap get(Integer type, String code) {
        Criterion typeEq = Restrictions.eq("type", type.intValue());
        Criterion codeEq = Restrictions.eq("code", code);
        return findUnique(typeEq, codeEq);
    }
}
